// importM
import 'package:flutter/material.dart';

// ignore: unused_import
import './MyIcon.dart';

import './res/listData.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter Demo",
      theme: ThemeData(primarySwatch: Colors.blue),
      home: Scaffold(
        appBar: AppBar(
          title: Text("Flutter App", style: TextStyle(color: Colors.white)),
          backgroundColor: Colors.deepPurple,
        ),
        body: Search(),
      ),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(child: Text("Hello Flutter"));
  }
}

class WrapDemo extends StatelessWidget {
  const WrapDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(10),
      child: Wrap(
        // 横向间距
        spacing: 10,
        // 竖向间距
        runSpacing: 10,
        // 默认为垂直方向
        //direction: Axis.vertical,
        // 居中
        alignment: WrapAlignment.center,
        children: [
          Button("1", onPressed: () {}),
          Button("2", onPressed: () {}),
          Button("3", onPressed: () {}),
          Button("4", onPressed: () {}),
          Button("5", onPressed: () {}),
          Button("6", onPressed: () {}),
          Button("7", onPressed: () {}),
          Button("8", onPressed: () {}),
          Button("9", onPressed: () {}),
          Button("10", onPressed: () {}),
        ],
      ),
    );
  }
}

class Search extends StatelessWidget {
  const Search({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView(
      padding: EdgeInsets.all(10),
      children: [
        Row(
          children: [Text("热搜", style: Theme.of(context).textTheme.titleLarge)],
        ),
        Divider(),
        Wrap(
          // 横向间距
          spacing: 15,
          // 竖向间距
          runSpacing: 10,
          children: [
            Button("女装", onPressed: () {}),
            Button("ROG B850 Gaming -G WIFI 吹雪", onPressed: () {}),
            Button("男装", onPressed: () {}),
            Button("狗粮", onPressed: () {}),
            Button("5090", onPressed: () {}),
          ],
        ),
        SizedBox(height: 30),
        Row(
          children: [
            Text("历史记录", style: Theme.of(context).textTheme.titleLarge),
          ],
        ),
        Divider(),
        Column(
          children: [
            ListTile(title: Text("ROG B850 Gaming -G WIFI 吹雪")),
            Divider(),
            ListTile(title: Text("AMD Ryzen7 9800X3D")),
            Divider(),
            ListTile(title: Text("芝奇皇家戟 16x2 6000 c28 AMD EXPO")),
            Divider(),
          ],
        ),
        OutlinedButton.icon(
          onPressed: () {},
          style: ButtonStyle(
            foregroundColor: MaterialStateProperty.all(Colors.blue),
            
          ),
          label: Text("清除历史记录"),
          icon: Icon(Icons.delete),
        ),
      ],
    );
  }
}

class Button extends StatelessWidget {
  final String text;
  final void Function()? onPressed;

  const Button(this.text, {super.key, required this.onPressed});

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(onPressed: onPressed, child: Text(text));
  }
}
